Skip to main content

Aggregations Repository

  • Stores the default chart aggregation

  • Stores the user's list of aggregations

  • The interface for the repository is AggregationsRepository. The repository is mandatory for the library to function and is passed to com.devexperts.dxcharts.lib.domain.DxChartsConfig. The standard implementation is com.devexperts.dxcharts.lib.data.implementation.DefaultAggregationsRepository.

AggregationRepository Interface:

/**
* Interface for the repository to store aggregation data.
*
* Aggregation is used when retrieving candle data from the corresponding provider.
*
* On the first run of the library, [getSelectedAggregation] should return the default aggregation.
*
* Implementation of this interface is mandatory for the library to function. It is passed to [com.devexperts.dxcharts.lib.domain.DxChartsConfig].
*
* The standard implementation is [com.devexperts.dxcharts.lib.data.repo.default_repos.DefaultAggregationsRepository].
*
* @see Aggregation
*/
interface AggregationsRepository {
/**
* Adds a new aggregation to the list of available aggregations for selection.
*/
fun addAggregation(aggregation: Aggregation)
/**
* Sets the selected aggregation.
*/
fun setSelectedAggregation(aggregation: Aggregation)
/**
* Returns a list of all aggregations for display on the aggregation selection screen.
*
* @return List of all aggregations
*/
fun getAggregations(): List<Aggregation>
/**
* Removes an aggregation from the list of available aggregations for selection.
*/
fun removeAggregation(aggregation: Aggregation)
/**
* Returns the currently selected or default aggregation.
*
* @return Selected aggregation
*/
fun getSelectedAggregation(): Aggregation
}
/*****/
data class Aggregation(
val value: Int,
val multiplier: TimeUnit = TimeUnit.SECONDS,
)